import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import alias from "@rollup/plugin-alias"
import path from 'path'
// import CopyWebpackPlugin from 'copy-webpack-plugin'
import cesium from 'vite-plugin-cesium'
// https://vitejs.dev/config/

const projectRootDir = path.resolve(__dirname);
console.log('projectRootDir', projectRootDir)
export default defineConfig({
    // resolve:{
    //     'src': path.resolve(__dirname,"src"),
    //     '~/': path.resolve(__dirname,"src"),
    //     // '@': path.resolve(__dirname,"src"),
    // },
    // server: {
    //
    //     proxy: { // 配置本地代理地址
    //         '/dev': 'http://xxx.xxx.com/api'
    //     }
    // },
    plugins: [
        vue(),
        // new CopyWebpackPlugin([{
        //     from: path.join('node_modules/cesium/Source', '../Build/Cesium/Workers'),
        //     to: 'Workers',
        // }]),
        // new CopyWebpackPlugin([{ from: path.join('node_modules/cesium/Source', 'Assets'), to: 'Assets' }]),
        // new CopyWebpackPlugin([{ from: path.join('node_modules/cesium/Source', 'Widgets'), to: 'Widgets' }]),
        // new webpack.DefinePlugin({
        //     // Define relative base path in cesium for loading assets
        //     CESIUM_BASE_URL: JSON.stringify(''),
        // }),
        //note vite 加载cesium
        cesium(),
        //note 处理路径别名识别
        alias({
            entries: [
                {
                    find: 'src',
                    replacement: path.resolve(projectRootDir, 'src'),
                },
                {
                    find: '@',
                    replacement: path.resolve(projectRootDir, 'src/'),
                },
                {
                    find: '~/',
                    replacement: path.resolve(projectRootDir, 'src'),
                },
                {
                    find: '@@',
                    replacement: path.resolve(projectRootDir, 'src'),
                },
            ],
        }),
    ],
    server:{
        // note: 自定义启动端口
        port: 3005,
        //note: open支持boolean/string类型，为true时打开默认浏览器，为string类型时，打开指定浏览器，具体查看官网即可
        open: true,
        proxy:{
            '/api':'http://192.168.0.8:8001',
        }
    }

})
